import request from "@/utils/request"

// 注册接口
export const register = ({user_phone, password}) => {
  return request({
    url: '/user/register',
    method: 'post',
    data: {
      user_phone,
      password
    }
  })
}
// 登录接口(用户)
export const login = (user_phone, password) => {
  return request({
    url: '/user/login',
    method: 'post',
    data: {
      user_phone,
      password
    }
  })
}

// 用户修改密码
export const updtepass = ({user_phone, oldpassword,newpassword}) => {
  return request({
    url: '/user/changepwd',
    method: 'post',
    data: {
      user_phone,
      oldpassword,
      newpassword
    }
  })
}

// 获取单词
export const getWordList = (user_phone, start) => {
  return request({
    url: '/api/wordlist',
    method: 'post',
    data: {
      user_phone,
      start
    }
  })
}
// 删除单词
export const deleteWord = (id, user_phone) => {
  return request({
    url: '/api/delword',
    method: 'post',
    data: {
      id,
      user_phone
    }
  })
}

// 查找单个单词
export const findLone = (id) => {
  return request({
    url: '/api/loneword',
    params: {
      id
    }
  })
}

// 更新单词
export const updateWord = ({ words, spell, meaning, word_id }) => {
  return request({
    url: '/api/updword',
    method: 'post',
    data: {
      words,
      spell,
      meaning,
      word_id
    }
  })
}
// 添加单词
export const addWord = ({ words, spell, meaning, user_phone}) => {
  return request({
    url: '/api/addword',
    method: 'post',
    data: {
      words,
      spell,
      meaning,
      user_phone
    }
  })
}
